import Vue from 'vue';
import Router from 'vue-router';
import Home from '../modules/home.vue';//首页
Vue.use(Router);
let router = new Router({
    routes: [
        { //首页
            path: '/',
            name: 'home',
            component: Home,
            meta: {title: '首页'}
        }
    ]
});
router.setTitle = function (title) {
    document.title = title;
    try {
        setTitle(title); //eslint-disable-line
    } catch (e) {
    }
};
router.beforeEach((to, from, next) => {
    window.onresize = () => {
        let screenWidth = window.screen.availWidth;
        console.log(screenWidth)
        if (screenWidth > 750) {
            location.href = "/pc.html#/"
        }
    }

    next();
});
router.afterEach(route => {
    /** set title */
    if (route.meta && route.meta.title) {
        router.setTitle(route.meta.title);
    } else {
        router.setTitle("官网");
    }
});
export default router;
